home *** CD-ROM | disk | FTP | other *** search
- Path: urals.jpl.nasa.gov!user
- From: mlj@tazboy.jpl.nasa.gov (Mose L. Johnson)
- Newsgroups: comp.lang.c++,comp.sys.mac.programmer.help,comp.sys.mac.oop.misc,comp.sys.mac.oop.tcl
- Subject: [Q] Overloading operator ->
- Date: Tue, 09 Jan 1996 08:54:36 -0800
- Organization: Jet Propulsion Laboratory
- Message-ID: <mlj-0901960854360001@urals.jpl.nasa.gov>
- NNTP-Posting-Host: urals.jpl.nasa.gov
- Mime-Version: 1.0
- Content-Type: text/plain; charset=US-ASCII
- Content-Transfer-Encoding: 7bit
-
- I am making a small interface for debuging prposes. The set of classes should
- allow the source to remain as close to its original form as possible. One
- of the things I am working on is Memory Management.
-
- One of the things I want to do is overload the arrow(->) operator. Here
- is an example of what I tried and want to do.
-
- ---
-
- template <class T> class ref<class T>
- {
- public:
- T* operator ->();
- };
-
- class tester
- {
- public:
- void member();
- };
-
- void main()
- {
- ref<tester *> var;
-
- var->member();
- }
-
- ---
-
- When I try to compile this, my compiler gives me an error of:
- illegal return type for operator->()
-
- If I declare that function as:
- ref<T *>* operator ->();
-
- it compiles, but my compiler returns an error of:
- member() is not a member of ref<tester *>
-
- How do I get 'ref<T*>::operator ->()' to return a pointer to class T.
-
- I am using Symantec C++ 7.0 on a Macintosh to compile my code.
-
- Your help will be welcomed. I need to have the interface by this weeks
- end. You can send a reply to me at:
- mlj@tazboy.jpl.nasa.gov
-
-
- Thanks in advance Mose L. Johnson.
-